﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using CSharpMathClassLibrary;


namespace _00_调用_委托_非委托_动态链接库
{
    internal class Program
    {
        static void Main(string[] args)
        {
            int a = 1;
            int b = 2;

            CSharpMath cSharpMath = new CSharpMath();

            //打印输出加减乘除
            int result1 = cSharpMath.Add(a, b);
            Console.WriteLine("{0}+{1}={2}",a,b,result1);

            int result2 = cSharpMath.Subtract(a, b);
            Console.WriteLine("{0}-{1}={2}", a, b, result2);

            int result3 = cSharpMath.Multiply(a, b);
            Console.WriteLine("{0}*{1}={2}", a, b, result3);

            double result4 = cSharpMath.Divide(a, b);
            Console.WriteLine(@"{0}\{1}={2}", a, b, result4);

            Console.WriteLine("===========================================");

            //调用VB.NET 的动态链接库
            MathClassLibrary.MyMath myMath = new MathClassLibrary.MyMath();

             Console.WriteLine(myMath.Add(a,b));
            Console.WriteLine(myMath.Subtract(a, b));
            Console.WriteLine(myMath.Multiply(a, b));
            Console.WriteLine(myMath.Divide(a, b));

            Console.WriteLine("============================================");

            Console.WriteLine("{0}+{1}={2}", a, b, Add(a, b));
            Console.WriteLine("{0}-{1}={2}", a, b, Sub(a, b));
            Console.WriteLine("{0}*{1}={2}", a, b, Mul(a, b));
            Console.WriteLine("{0}/{1}={2}", a, b, Div(1.0, 2.0));


            Console.Read();
        }

        [DllImport("C:\\Users\\Admin\\source\\repos\\3_25_委托_事件_多线_学习\\x64\\Debug\\MathDll.dll")]
        public static extern int Add(int a, int b);


        [DllImport("C:\\Users\\Admin\\source\\repos\\3_25_委托_事件_多线_学习\\x64\\Debug\\MathDll.dll")]
        public static extern int Sub(int a, int b);

        [DllImport("C:\\Users\\Admin\\source\\repos\\3_25_委托_事件_多线_学习\\x64\\Debug\\MathDll.dll")]
        public static extern int Mul(int a, int b);

        [DllImport("C:\\Users\\Admin\\source\\repos\\3_25_委托_事件_多线_学习\\x64\\Debug\\MathDll.dll")]
        public static extern double Div(double a, double b);

    }
}
